package com.czk.scala.chapter01

/**
 * @Author:ChenZhangKun
 * @Date: 2021/12/6 16:41
 */
class Student(name: String, var age: Int) {
  /**
   * c此时构造方法已经存在了
   */
  def printInfo(): Unit = {
    println(this.name + " " + this.age+" "+Student.school)
  }
}

// 引入伴生对象,创建静态变量
object Student {
  val school: String = "清华"

  def main(args: Array[String]): Unit = {
    // 定义对象
    val student = new Student("czk",27)
    val student2=new Student("nzq",26)
    student.printInfo()
    student2.printInfo()
  }
}
